<?php
/**
 * Minhlog Domain_Model 文章评论类
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   Domain
 * @package    Domain_Model
 * @copyright  Copyright (c) 2009-2010 Minh.Shu@gmail.com
 * @license    New BSD License
 * @author     Minh.Shu
 * @version    $Id: Comment.php 2 2010-01-17 13:49:08Z Minh.Shu $
 *
 */

class Domain_Model_Comment
{
    private $_commentDataMapper;
    private $_commentEntity;

    public function  __construct()
    {
        $this->_commentDataMapper = new Domain_DataMapper_Comment();
        $this->_commentEntity = new Domain_Entity_Comment();
        $this->_commentDataMapper->setEntity($this->_commentEntity);
    }

    /**
     * 根据文章查询评论
     * @param integer $articleId
     * @return object|void
     */
    public function getCommentByArticle($articleId)
    {
        $articleId = (int) $articleId;
        return $this->_commentDataMapper->findCommentByArticle($articleId);
    }

    /**
     * 根据主键ID查询评论
     * @param integer $commentId
     * @return object|void
     */
    public function getCommentById($commentId)
    {
        $commentId = (int) $commentId;
        $resultSet = $this->_commentDataMapper->findByPrimaryId($commentId);
        return $resultSet;
    }

    /**
     * 查询全部评论
     * @return object|void
     */
    public function getAllComment()
    {
        return $this->_commentDataMapper->findAllComment();
    }

    /**
     * 保存评论信息
     * @param array $commentData
     * @param integer $primaryId
     * @return
     */
    public function saveComment($commentData, $primaryId = 0)
    {
        $primaryId = (int) $primaryId;
        return $this->_commentDataMapper->save($commentData, $primaryId);
    }

    /**
     * 删除评论信息
     * @param integer $primaryId
     * @return
     */
    public function delComment($primaryId)
    {
        $primaryId = (int) $primaryId;
        return $this->_commentDataMapper->delete($primaryId);
    }
}